//16进制转换成rgba
function transform(num) {
    // if (parseInt(num, 16)) {
    //     return `#${num}`;
    // }
    //转换成3个数组
    let i = 0;
    let list = [];
    let num1 = num.split('');
    let size = num1.length;
    while (i < num1.length) {
        if (size == 3) {
            let temp = num1[i] + num1[i];
            list.push(temp)
            i++;
        }
        if (size == 6) {
            let temp = num1[i] + num[i + 1];
            list.push(temp)
            i = i + 2;
        }
    }
    //转换rgb格式
    let r = parseInt(list[0], 16);
    let g = parseInt(list[1], 16);
    let b = parseInt(list[2], 16);
    console.log('r.toString(16)', r.toString(16), typeof r.toString(16));
    if (r.toString(16)) {

    }
    return `rgb(${r}, ${g}, ${b})`;
}

console.log(transform('F2FFFF'),
    transform('FFF'),
    transform('123456'));